package com.example.demo.niuke.huawei_b;

import java.util.Scanner;

/**
 * ******************************************************
 *
 * @author liugh9
 * @version 1.0
 * @classname Main2
 * @description
 * @date 2023/09/02 15:16
 * <p>
 * ******************************************************
 */
public class Main2 {


    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long[] preSum = new long[n + 1];
//        in.nextLine();
//        String[] split = in.nextLine().split(" ");
//        for (int i = 0; i < split.length; i++) {
//            preSum[i+1] = preSum[i] + Integer.parseInt(split[i]);
//        }
        int p = 1;
        while (p <= n) {
            long next = in.nextLong();
            preSum[p] = preSum[p - 1] + next;
            p++;
        }
        long max = Long.MIN_VALUE;
        for (int i = 1; i < preSum.length - 1; i++) {
            max = Math.max(Math.abs(preSum[n] - preSum[i] - preSum[i]), max);
        }
        System.out.println(max);
    }
}
